<?php
/**
 * @Author       : fanjinghua
 * @LastEditors  : fanjinghua
 * @LastEditTime : 2022/3/7 17:44
 * @Description  : 佛祖保佑,永无BUG
 */

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::group([
    'namespace' => 'App\Http\Controllers\Admin\V1',
    'prefix' => 'v1'
], function () {
    Route::post('/login', 'AdminController@login');
});

Route::group([
    'prefix' => 'v1',
    'namespace' => 'App\Http\Controllers\Admin\V1',
    'middleware' => 'auth:admin',
], function () {

    // 拉取用户菜单
    Route::get('/menus/show', 'MenuController@menuShow');
    // 获取登录信息
    Route::post('/me', 'AdminController@me');
    // 退出登录
    Route::post('/logout', 'AdminController@outLogin');

    Route::group([
        'middleware' => 'auth.permission'
    ], function () {

        // 管理员管理
        Route::post('admin/lists', 'AdminController@lists');
        Route::post('admin/create', 'AdminController@create');
        Route::put('admin/update/{id}', 'AdminController@update');
        Route::delete('admin/delete/{id}', 'AdminController@delete');

        // 菜单相关路由
        Route::post('menu/create', 'MenuController@create');
        Route::put('menu/edit/{id}', 'MenuController@update');
        Route::delete('menu/delete/{id}', 'MenuController@delete');
        Route::get('menus', 'MenuController@lists');
        Route::get('menus/select', 'MenuController@menuSelect');
        Route::put('menus/is-display/{id}', 'MenuController@isDisplay');


        // 权限相关路由
        Route::post('permission/create', 'PermissionController@create');
        Route::put('permission/edit/{id}', 'PermissionController@update');
        Route::delete('permission/delete/{id}', 'PermissionController@delete');
        Route::post('permission/generate', 'PermissionController@generateAllPermission');
        Route::get('permissions', 'PermissionController@lists');


        // 角色相关路由
        Route::post('role/create', 'RoleController@create');
        Route::put('role/edit/{id}', 'RoleController@update');
        Route::delete('role/delete/{id}', 'RoleController@delete');
        Route::get('roles', 'RoleController@lists');
        Route::get('roles/all', 'RoleController@checkBoxList');
        Route::get('role/{role_id}/menus/permissions', 'RoleController@hasMenuPermission');
        Route::post('role/{role_id}/menus/permissions', 'RoleController@setMenuPermission');
    });

});
